package bb.lanxing.lib.devices.common;

import android.os.Parcel;
import android.os.Parcelable;
import bb.lanxing.lib.devices.api.SmartDevice;

public class DeviceInfo implements SmartDevice, Parcelable {
    public static final Parcelable.Creator<DeviceInfo> CREATOR = new Parcelable.Creator<DeviceInfo>() {
        @Override
        public DeviceInfo createFromParcel(Parcel parcel) {
            return new DeviceInfo(parcel);
        }

        @Override
        public DeviceInfo[] newArray(int i) {
            return new DeviceInfo[i];
        }
    };
    private String address;
    private int flags;
    private String name;
    private int protocol;
    private int rssi;
    private byte[] scanRecord;
    private int type;

    @Override
    public int describeContents() {
        return 0;
    }

    public DeviceInfo() {
    }

    protected DeviceInfo(Parcel parcel) {
        readFromParcel(parcel);
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String str) {
        this.name = str;
    }

    @Override
    public String getAddress() {
        return this.address;
    }

    @Override
    public void setAddress(String str) {
        this.address = str;
    }

    @Override
    public int getProtocol() {
        return this.protocol;
    }

    @Override
    public void setProtocol(int i) {
        this.protocol = i;
    }

    @Override
    public int getType() {
        return this.type;
    }

    @Override
    public void setType(int i) {
        this.type = i;
    }

    @Override
    public int getFlags() {
        return this.flags;
    }

    @Override
    public void setFlags(int i) {
        this.flags = i;
    }

    @Override
    public int getRssi() {
        return this.rssi;
    }

    @Override
    public void setRssi(int i) {
        this.rssi = i;
    }

    @Override
    public byte[] getScanRecord() {
        return this.scanRecord;
    }

    @Override
    public void setScanRecord(byte[] bArr) {
        if (bArr != null || bArr.length >= 4) {
            this.scanRecord = bArr;
        }
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.name);
        parcel.writeString(this.address);
        parcel.writeInt(this.protocol);
        parcel.writeInt(this.type);
        parcel.writeInt(this.flags);
    }

    @Override
    public void readFromParcel(Parcel parcel) {
        this.name = parcel.readString();
        this.address = parcel.readString();
        this.protocol = parcel.readInt();
        this.type = parcel.readInt();
        this.flags = parcel.readInt();
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        String str = this.address;
        String str2 = ((DeviceInfo) obj).address;
        return str != null ? str.equals(str2) : str2 == null;
    }

    public int hashCode() {
        String str = this.address;
        if (str != null) {
            return str.hashCode();
        }
        return 0;
    }
}
